package com.tuanzi.loan.business.service.settlementsystem.impl;

import com.tuanzi.loan.business.entity.settlementsystem.SettlementCompany;
import com.tuanzi.loan.business.repository.settlementsystem.SettlementCompanyRepository;
import com.tuanzi.loan.business.service.settlementsystem.SettlementCompanyService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.repository.JPAAuditRepository;
import com.tuanzi.loan.core.service.BaseAuditServiceImpl;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.settlementsystem.SettlementCompanyAmountRequest;
import com.tuanzi.loan.vo.request.settlementsystem.SettlementCompanyRequest;
import com.tuanzi.loan.vo.response.settlementsystem.SettlementCompanyResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author caiwanlin
 * @create 2018-08-16 20:03
 */
@Debug
@Service
@Transactional
@Retryable(value = {RetryException.class})
public class SettlementCompanyServiceImpl extends BaseAuditServiceImpl<SettlementCompany,Long> implements SettlementCompanyService {
    @Autowired
    private SettlementCompanyRepository settlementCompanyRepository;

    @Override
    public Page<SettlementCompanyResponse> list(PageSearcher<SettlementCompanyRequest> pageSearcher) {
        return settlementCompanyRepository.list(pageSearcher.getSearchCondition(),pageSearcher.getPageable());
    }

    @Override
    public Page<SettlementCompanyResponse> listAmount(PageSearcher<SettlementCompanyAmountRequest> pageSearcher) {
        return settlementCompanyRepository.listAmount(pageSearcher.getSearchCondition(),pageSearcher.getPageable());
    }

    @Override
    public List<SettlementCompany> getCompanyList() {
        return settlementCompanyRepository.getCompanyList();
    }

    @Override
    public SettlementCompany findByCompanyName(String companyName) {
        return settlementCompanyRepository.findByCompanyName(companyName);
    }

    @Override
    protected JPAAuditRepository<SettlementCompany, Long> getRepository() {
        return settlementCompanyRepository;
    }
}
